package com.biu.billiards.response;


import com.biu.billiards.config.BaseErrorEnum;

public class RespGenerator {
    /**
     * 接口调用成功时出参
     *
     * @param data
     *            接口返回数据
     * @return
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static BaseResponse returnOK(Object data) {
        return new BaseResponse(BaseErrorEnum.SUCCESS.getResultCode(), "接口调用成功!", data);
    }

    /**
     * 调用失败
     *
     * @param code
     *            错误码
     * @param message
     *            错误信息
     * @return
     */
    public static BaseResponse<Object> returnError(BaseErrorEnum baseErrorEnum) {
        return new BaseResponse<Object>(baseErrorEnum.getResultCode(),baseErrorEnum.getResultMsg(), null);
    }

    /**
     * 调用失败
     *
     * @param message
     *            错误信息
     * @return
     */
    public static BaseResponse<Object> returnError(String code,String message) {
        return new BaseResponse<Object>(code, message, null);
    }



}
